package com.lilicould.dao;

import com.lilicould.entity.RepairRecord;
import com.lilicould.entity.RepairRequest;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;

public interface RepairDao {
    // 插入维修请求
    @Insert("insert into repair_request(request_id, building_id, apartment_no, description, report_date, repair_employee_id) values(#{requestId}, #{buildingId}, #{apartmentNo}, #{description}, #{reportDate}, #{repairEmployeeId})")
    int insertRepairRequest(RepairRequest repairRequest);

    // 插入报修记录
    @Insert("insert into repair_record(record_id, request_id, repair_date, content) values(#{recordId}, #{requestId}, #{repairDate}, #{content})")
    int insertRepairRecord(RepairRecord repairRecord);

    // 通过请求工单ID添加维修工
    @Update("update repair_request set repair_employee_id = #{employeeId} where request_id = #{requestId}")
    int updateRepairEmployeeId(@Param("requestId") String requestId,@Param("employeeId") String employeeId);

    // 查询所有报修请求
    @Select("select * from repair_request")
    ArrayList<RepairRequest> selectAllRepairRequests();

    // 查询所有维修记录
    @Select("select * from repair_record")
    ArrayList<RepairRecord> selectAllRepairRecords();

    // 通过请求工单ID删除报修请求
    @Delete("delete from repair_request where request_id = #{requestId}")
    int deleteRepairRequest(@Param("requestId") String requestId);
}
